<!DOCTYPE html>
<html>
<head>
	<title></title>
	<!--[if lt IE 9]>
	<meta http-equiv="refresh" content="0;ie.html" />
	<![endif]-->

	<link rel="shortcut icon" href="__STATIC__/layout/favicon.ico"> <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="__STATIC__/layout/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
	<link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
	<link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
	<link href="__STATIC__/layout/css/channel.css?v=4.1.0" rel="stylesheet">
	<link href="__STATIC__/layout/css/plugins/jsTree/style.min.css" rel="stylesheet">
	<script src="__STATIC__/layout/js/jquery.min.js"></script>
	<!-- Sweet Alert -->
	<link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
	<!-- Sweet alert -->
	<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
	<!-- layer javascript -->
	<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>

	<!-- ztree -->
	<link rel="stylesheet" href="__STATIC__/layout/css/zTreeStyle.css" type="text/css">
	<script type="text/javascript" src="__STATIC__/layout/js/jquery.ztree.core.js"></script>
	<script type="text/javascript" src="__STATIC__/layout/js/jquery.ztree.excheck.js"></script>
</head>
<body class="gray-bg">
<div class="ibox" >
	<div class="ibox-content">
		<div >
			<ul id="jstree1" class="ztree">

			</ul>
		</div>
		<div class="row">
			<div class="col-xs-12">
				<input class="btn btn-sm btn-primary pull-right m-t-n-xs" type="button" id="tijiao" value="确 定">

			</div>
		</div>

	</div>
</div>
<input type="hidden" id="renyuan">
<input type="hidden" id="renyuanname">

</body>
</html>
<script>
$(function () {

    var setting = {
        check: {
            enable: true,
            chkStyle: "radio",
            radioType: "all"
        },
        data: {
            simpleData: {
                enable: true
            }
        },
        callback:{
            onCheck: emOnCheck
        }
    };
    //员工树选择
    function emOnCheck(event, treeId, treeNode) {
        if(treeNode.checked==true){
			console.log(treeNode)
            $("#renyuan").val(treeNode.eid);
            $("#renyuanname").val(treeNode.name);

        }else{
            $("#renyuan").val('');
        }
    };

	$.post("{:url('Departments/getem')}",function(re){

		var data_em=JSON.parse(re);

		$.fn.zTree.init($("#jstree1"), setting, data_em);

	})

    var index = parent.layer.getFrameIndex(window.name);
    $('#tijiao').on('click',function () {

        var id =  $("#renyuan").val();
        var name =  $("#renyuanname").val();
        if(id){
            var testNoBtn = parent.layer.getChildFrame('#renyuan','{$_GET['frameindex']}')
            testNoBtn.html('<span class="ren" data-id="'+id+'">'+name+'<span class="close">×</span></span>')
            testNoBtn.attr('data-id',id)
		}

        parent.layer.close(index);
    })

})
</script>